Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
The de-indent npm package is a utility for removing leading indentation from multiline strings. This can be particularly useful when dealing with template literals in JavaScript, where you want to maintain readability in your code without preserving the indentation in the resulting string.
Basic De-indentation
This feature removes the leading indentation from a multiline string, making it easier to work with template literals without preserving the indentation in the final string.
const deindent = require('de-indent');
const indentedString = `
function example() {
console.log('Hello, world!');
}
`;
const result = deindent(indentedString);
console.log(result);
De-indentation with Template Literals
This feature is useful for de-indenting HTML or XML strings defined using template literals, making the code more readable while ensuring the final string has no leading spaces.
const deindent = require('de-indent');
const indentedString = `
<div>
<p>Hello, world!</p>
</div>
`;
const result = deindent(indentedString);
console.log(result);
The strip-indent package is another utility for removing leading whitespace from multiline strings. It works similarly to de-indent but offers a slightly different API. Both packages achieve the same goal, but developers might prefer one over the other based on personal preference or specific use cases.
The dedent package is a popular alternative that not only removes leading indentation but also handles escaping of backticks and interpolation of variables within template literals. It offers more features compared to de-indent, making it a more versatile choice for complex string manipulations.
FAQs
remove extra indent from a block of code
The npm package de-indent receives a total of 2,026,528 weekly downloads. As such, de-indent popularity was classified as popular.
We found that de-indent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.